/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Licensed under the Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *     http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef TEE_TP_PORTAL_H
#define TEE_TP_PORTAL_H

#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

#include "cgroup_util.h"

#define CONTAINER_ID_LEN 64
#define CONTAINER_OPEN 0x01
#define CONTAINER_STOP 0x02

enum TeePortalCmdType {
    CLEAN,
    RCONFIG,
    SEND_CONTAINER_MSG,
};

struct TeePortalSendContainerMsgType {
    char containerId[CONTAINER_ID_LEN];
    uint32_t mode;
};

struct TeePortalCleanType {
    int grpId;
};

struct TeePortalType {
    enum TeePortalCmdType type;
    int ret;
    uint32_t reeUID;
    uint32_t sessionID;
    uint32_t nsId;
    union Args1 {
        struct TeePortalSendContainerMsgType containerMsg;
        struct TeePortalCleanType clean;
        struct TeePortalRConfigType rconfig;
    } args;
};

int InitPortal(void);
int GetPortal(void **portal, uint32_t *portalSize);
int TriggerPortal(void);
void DestroyPortal(void);
#endif
